var  app  = new Vue({
    el:"#assignRole",
    data:{
        users:[],
        roles:[],
    },
    methods:{
        getAllUsers:function(){

            $.get("user/userList",function(r){
                app.users =  r.userList;
            });
        },
        findUserNotHasRole:function(){
            var userId = $("#users option:checked").val();
            //alert(userId);
            $.get("user/notHasRole/"+userId,function (r) {

                app.roles = r.roles;
            });

        },
        assignRole:function () {
            var userId=$("#users option:checked").val();
            var roleId=$("#hasRole option:checked").val();
            $.get("user/addRole/"+userId+"/"+roleId,function(r){
                if (r.code==0){
                    alert('添加成功');

                }

            });
        }
    },
    created:function(){
        this.getAllUsers();
    }

});